package dao

import (
	"errors"
	"fmt"
	"project_base_framework/entity"
	"project_base_framework/params"
	"project_base_framework/utils"
)

type UserDAO struct {
}

func NewUserDAO() *UserDAO {
	return &UserDAO{}
}

// Login 登录查找用户
func (userDAO *UserDAO) Login(loginParamVO *params.LoginParamVO) (*entity.User, error) {
	user := new(entity.User)
	err := utils.DB.Debug().Where("username=?", loginParamVO.Username).First(user).Error
	if err != nil {
		fmt.Println("user not exist err =", err.Error())
		return nil, errors.New("user not exist")
	}
	return user, nil
}
